package com.taiji.workOrder.service.impl;

import java.util.List;
import com.taiji.common.utils.DateUtils;
import com.taiji.common.utils.SecurityUtils;
import com.taiji.workOrder.Utils.Const;
import com.taiji.workOrder.domain.WorkOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.taiji.workOrder.mapper.LeftProblemMapper;
import com.taiji.workOrder.service.ILeftProblemService;

/**
 * 遗留问题Service业务层处理
 * 
 * @author taiji
 * @date 2023-03-19
 */
@Service
public class LeftProblemServiceImpl implements ILeftProblemService 
{
    @Autowired
    private LeftProblemMapper leftProblemMapper;

    /**
     * 查询遗留问题
     * 
     * @param id 遗留问题主键
     * @return 遗留问题
     */
    @Override
    public WorkOrder selectLeftProblemById(String id)
    {
        return leftProblemMapper.selectLeftProblemById(id);
    }

    /**
     * 查询遗留问题列表
     * 
     * @param leftProblem 遗留问题
     * @return 遗留问题
     */
    @Override
    public List<WorkOrder> selectLeftProblemList(WorkOrder leftProblem)
    {
        leftProblem.setStatus(Const.WorkOrderStatus.CLOSED.getKey());
        String username = SecurityUtils.getUsername();
        leftProblem.setCreateBy(username);
        return leftProblemMapper.selectLeftProblemList(leftProblem);
    }

    /**
     * 新增遗留问题
     * 
     * @param leftProblem 遗留问题
     * @return 结果
     */
    @Override
    public int insertLeftProblem(WorkOrder leftProblem)
    {
        leftProblem.setCreateTime(DateUtils.getNowDate());
        return leftProblemMapper.insertLeftProblem(leftProblem);
    }

    /**
     * 修改遗留问题
     * 
     * @param leftProblem 遗留问题
     * @return 结果
     */
    @Override
    public int updateLeftProblem(WorkOrder leftProblem)
    {
        leftProblem.setUpdateTime(DateUtils.getNowDate());
        return leftProblemMapper.updateLeftProblem(leftProblem);
    }

    /**
     * 批量删除遗留问题
     * 
     * @param ids 需要删除的遗留问题主键
     * @return 结果
     */
    @Override
    public int deleteLeftProblemByIds(String[] ids)
    {
        return leftProblemMapper.deleteLeftProblemByIds(ids);
    }

    /**
     * 删除遗留问题信息
     * 
     * @param id 遗留问题主键
     * @return 结果
     */
    @Override
    public int deleteLeftProblemById(String id)
    {
        return leftProblemMapper.deleteLeftProblemById(id);
    }
}
